
/***************************************************************************\
*
* DESCRIPTION:  Public definitions for ISDN interface.
*
* Copyright (c) 1995-2002 NMS Communications.  All rights reserved.
*
\***************************************************************************/

/*--------------------------------------------------------------------------*
 *                       M O D U L E   H E A D E R
 *
 * filename - isdndl.h
 *
 * $Revision:   3.42  $
 *
 * $Date:   15 Jan 1998 10:06:38  $
 *
 *	Header implementing the	DL upper interface definitions and declarations of
 *  the OMNITEL_BRICKS package.
 *
 *-------------------------------------------------------------------------*/

/*[]---------------------------------------------------[]*/
/*|                                                     |*/
/*|    LAP-BRICKS                                       |*/
/*|    ISDN-BRICKS                                      |*/
/*|    X25-BRICKS                                       |*/
/*|                                                     |*/
/*|    Data-Link Layer                                  |*/
/*|                                                     |*/
/*|    Copyright (c) 1989-1998 by OMNITEL SA            |*/
/*|    All Rights Reserved.                             |*/
/*|                                                     |*/
/*[]---------------------------------------------------[]*/
#ifdef __cplusplus
extern "C" {
#endif

#ifndef DL_INT
#define DL_INT

#ifndef DL_STATISTICS
#	define DL_STATISTICS	OFF			/* Statistics reports thru SM_INFO_RQ/CO */
#endif

//  RJB:  2/15/2003 -- This define controls whether or not DL_EST_RQ's are
//  acted upon when you are already in multiframe operation.

#ifndef DL_MFO_WORKAROUND
#define DL_MFO_WORKAROUND ON
#endif

/*--------------------------------------------------------------------------*/

			/* DL upper layer parameters */

#define DL_D			 	0					/* DL LAPD entity */
#define DL_B				1					/* DL LAPB entity */
#define MDL					2					/* MDL entity */
#define DL_F				3					/* DL LAPF entity */

			/* DL SAPI : Data Link service access point identifiers */

#define DL_SAPI_SIG			(uchar)0			/* signalling DL SAPI */
#define DL_SAPI_PCK_D		(uchar)1			/* signalling for packet using D signalling */
#define DL_SAPI_ECL         (uchar)2			/* ECL SAPI */
#define DL_SAPI_X25			(uchar)16  			/* packet X25 DL SAPI */
#define DL_SAPI_MDL  		(uchar)63			/* management DL SAPI */
#define DL_SAPI_LAPB		(uchar)0			/* SAP address used for LAPB protocol in B channel */
#define DL_SAPI_ISDN_BIOS	(uchar)32			/* SAP address used for LAPB ISDN-BIOS end of NCB flag */
#define DL_SAPI_MLP			(uchar)254			/* SAPI address used for MLP */
#define DL_SAPI_INVALID		(uchar)126			/* used as invalid DL D SAPI */
#define DL_SAPI_NIL			(uchar)SAPI_NIL		/* SAPI NIL */

				/* DL SAPI for LAP4K */

#define DL_SAPI_LAP4K_MDL	(uchar)63			/* SAPI LAP4K management */
#define DL_SAPI_LAP4K_L3	(uchar)0			/* SAPI LAP4K data */

				/* DL SAPI for LAPF */

#define DL_SAPI_LAPF_MDL	(WORD)63          /* SAPI LAPF management */
#define DL_SAPI_LAPF_L3		(uchar)0			/* SAPI LAPF data */

				/* V.120 LLI values */

#define DL_LLI_SIG			(WORD)0			/* LLI for in channel signalling */
#define DL_LLI_NIL          (WORD)1			/* LLI NIL */
#define DL_LLI_DEFAULT		(WORD)256			/* default LLI */
#define DL_LLI_ASSIGNMENT	(WORD)257			/* First LLI assignment value */
#define DL_LLI_MGT			(WORD)8191		/* In channel layer management */

				/* DLCI NIL */

#define DL_DLCI_NIL			(WORD)(~0)		/* DLCI NIL value */

				/* LAP4K DLCI */

#define DL_DLCI_LAP4K_MGT	(WORD)8191		/* DLCI management value */

				/* LAPF DLCI Management */

#define DL_DLCI_LAPF_2_MGT	(WORD)992
#define DL_DLCI_LAPF_3_MGT	(WORD)63488
#define DL_DLCI_LAPF_4_MGT	(DWORD)126976L

				/* PH priority class for DL frame */

#define DL_PRIORITY_SIG		1					/* Signalling frame : upper priority */
#define DL_PRIORITY_NO_SIG	2					/* Non signalling frame : lower priority */
#define DL_PRIORITY_NIL		((uchar)(~0))		/* priority NIL */

			/* DL CES : Connection Endpoint Suffix */

#define DL_CES_BROADCAST	(uchar)0			/* ces affected to broadcast */
#define DL_CES_SIG			(uchar)1			/* first ces affected to signalling */
#define	DL_CES_NIL			((ces_t)~0)

			/* DL max header size */

#if DL_MLP == ON
#	define DL_MX_FRAME_HEADER	8				/* maximum length of the frame header (MLP) */
#else
#	define DL_MX_FRAME_HEADER	4				/* maximum length of the frame header (SLP) */
#endif

			/* Miscelleanous NIL constants for unpacked values */

#define	DL_CR_NIL			(uchar)0xff
#define	DL_FORMAT_NIL		(uchar)0xff
#define	DL_COMMAND_NIL		(uchar)0xff
#define	DL_PF_NIL			(uchar)0xff

/*--------------------------------------------------------------------------*/

					/* DL and MDL PRIMITIVES CODES */

						/* L3 <----> DL */

#define DL_EST_RQ			'A'					/* request establishing multiple operation */
#define DL_U_EST_RQ			'B'					/* request establishing simple operation */
#define DL_EST_IN			'a'					/* establishing single or multiple frame operation indication*/
#define DL_U_EST_IN			'i'					/* establishing simple frame operation */
#define DL_EST_CO			'b'     			/* confirm for establishing single or multiple frame operation */

#define DL_REL_RQ			'C'					/* request for terminating single or multiple frame operation */
#define DL_REL_IN			'c'					/* terminating single or multiple frame operation indication */
#define DL_REL_CO			'd'					/* confirm for terminating single or multiple frame operation */

#define DL_DA_RQ			'E'					/* request for passing messages from L3 using acknowledged operation */
#define DL_DA_IN			'e'					/* passing messages to L3 using acknowledged operation indication */
#define DL_DA_CO			'q'					/* confirmation remote acknowledge of I frame */
#define DL_ACK_CO			'k'					/* DL acknowledge confirm */

#define DL_U_DA_RQ			'F'					/* request for passing messages from L3 using unacknowlegded operation */
#define DL_U_DA_IN			'f'					/* passing messages to L3 using unacknowledged operation indication */

#define DL_COMMIT_RQ		'G' 				/* DL request commitment */
#define DL_COMMIT_CO		'g'					/* DL commitment confirm */

/* NMS_FIX SS 060199 D-channel backup */
#define DL_DM_RLS			'?' 				/* internal event: sets maintenance busy flag */
/* End */
#define WAIT_ACK			'*'					/* internal event : pending remote ackowledgment */

						/* MDL <-----> DL */

#define MDL_AS_TEI_RQ		'H'					/* request that DL associate the TEI value with the CES */
#define MDL_AS_TEI_IN	 	'h'					/* indication to the management the need for a TEI value */

#define MDL_RM_TEI_RQ		'I'					/* request that the DL remove the association of the TEI value with the specified CES */

#define MDL_ATTACH_SAPI_RQ	'J'					/* request that DL associate the TEI value with the CES */
#define MDL_SAPI_CO		 	'j'					/* indication to the management the need for a TEI value */

#define MDL_DETACH_SAPI_RQ	'K'					/* request that the DL remove the association of the TEI value with the specified CES */

#define MDL_ERR_RS			'M'					/* response from the management if it cannot obtain a TEI value */
#define MDL_ERR_IN			'm'					/* indicate to the management that an unrecoverable error has occurred */

#define MDL_U_DA_RQ			'N'					/* request for passing messages, which are to be transmitted, to DL using unacknowledged operation */
#define MDL_U_DA_IN			'n'					/* indicate for passing messages,which have been received, from DL using unacknowledged operation */

#define MDL_XID_RQ			'O'					/* request  XID frame */
#define MDL_XID_IN			'o'					/* indication XID frame */
#define MDL_XID_RS			'P'					/* response XID frame */
#define MDL_XID_CO			'p'					/* confirm XID frame */

#define MDL_BUSY_RQ			'Q'					/* request for busy state / na */
#define MDL_CLEAR_BUSY_RQ 	'R'					/* request for clearing busy state / na */

/* NMS_FIX SS 060199 D-channel backup */
#define MDL_DM_RLS			'!' 				/* internal event: sets maintenance busy flag  */
/* End */

#define MDL_SET_CONFIG_RQ	'S'					/* request configuration and initialization DL */
#define MDL_SET_CONFIG_CO	's'					/* confirmation of DL configuration and initialization */

#define MDL_XID_RESET_RQ	'T'					/* MDL XID reset request */

#define MDL_STOP_RQ			'U'					/* MDL stop request */
#define MDL_STOP_CO			'u'					/* MDL stop confirm */

#define MDL_RESET_CONFIG_RQ	'V'					/* MDL reset configuration request */
#define MDL_RESET_CONFIG_CO 'v'					/* MDL reset configuration confirm */

						/* Management Connection */

#define MC_PARAM_RQ			'W'					/* MC Request parameter negotiation */
#define MC_PARAM_CO			'w'					/* MC Parameter negotiation confirm */

#define MC_PARAM_ERROR_IN	'x'					/* MC Parameter error indication */

#define MC_ERR_IN			'y'					/* MC Error indicate */

						/* MDL INFO request */

#define MDL_INFO_RQ			'Z'					/* MDL information request */
#define MDL_INFO_CO			'z'					/* MDL information confirm */

						/* DLCI management from upper layer : V120 and LAP4K */

#define MDL_AS_DLCI_RQ		'A'					/* Request DLCI assignment to CES */
#define MDL_AS_DLCI_IN		'a'					/* Indication DLCI assignment to CES */
#define MDL_AS_DLCI_RS		'B'					/* Response DLCI assignment to CES */
#define MDL_AS_DLCI_CO		'b'					/* Confirmation DLCI assignment to CES */

#define MDL_RM_DLCI_RQ		'C'					/* Request DLCI removal */
#define MDL_RM_DLCI_IN		'c'					/* Indication DLCI removal */
#define MDL_RM_DLCI_CO		'D'					/* confirm DLCI removal */

#define MDL_INFO_DLCI_IN	'd'					/* Indication DLCI information */

						/* DL flow control management */

#define DL_BUSY_RQ			'('					/* request  incoming flow ON */
#define DL_BUSY_IN			')'					/* indicate outgoing flow ON */

#define DL_CLEAR_BUSY_RQ	'['					/* request incoming flow OFF */
#define DL_CLEAR_BUSY_IN	']'					/* indicate outgoing flow OFF */

#define DL_INT_SYNC_RQ		'+'					/* request flow interface synchronization */
#define DL_INT_SYNC_CO		'-'					/* confirm flow interface fsynchronisation */

						/* DL and MDL timer events */

#define TI_200				'0'					/* timer 200 expired */
#define TI_201				'1'					/* timer 201 expired */
#define TI_202				'2'					/* timer 202 expired */
#define TI_203				'3'					/* timer 203 expired */
#define TI_204				'4'					/* timer 204 expired */
#define TI_205				'5'					/* timer clear error counters expired */

#define TI_V120_XID			'7'					/* timer V120 XID expired */
#define TI_XID				'8'					/* timer XID expired */

#define TI_XT1				'9'					/* timer LAPX expired */

						/* MLP timer events */

#define TI_MT1				'1'					/* timer MT1 expired */
#define TI_MT2				'2'					/* timer MT2 expired */
#define TI_MT3				'3'					/* timer MT3 expired */

						/* DLX (LAPX) primitives */

#define DLX_REL_RQ			'A'					/* LAPB is in a disconnect phase */
#define DLX_TX_STOP_RQ		'B'					/* LAPB has finished transmitting one or more frame */

#define DLX_TX_ENABLE_IN	'c'					/* LAPX enable LAPB to send frames */
#define DLX_TX_DISABLE_IN	'd'					/* LAPX inhibit LAPB from sending frames */

#define DL_EV_CONNECTION_OFF OFF				/* Report event : DL connection released */
#define DL_EV_CONNECTION_ON  ON					/* Report event : DL connection established */

/*--------------------------------------------------------------------------*/

		/*	MDL ERROR INDICATION : DL to MDL for error reporting. */

struct mdl_error {
		struct sm_report dl_report;		/* report structure */

		ent_id_t	    event_from;		/* event origination */
		code_t			code;			/* message primitive code at the origination of the error */
		uchar			cause;			/* error cause */
		sapi_t 			sapi;			/* sapi */
		WORD 			tei;			/* tei or DLCI */
		uchar 			ces;			/* ces */
		uchar 			chani;			/* channel identifier */
		uchar 			cr;				/* command response bit */
		uchar 			format;			/* format (i,s,u) */
		uchar 			command;		/* command code */
		uchar 			pf;				/* poll/final bit */
		uchar 			ns;				/* ns sequense number */
		uchar 			nr;				/* nr sequence number */
		uchar 			vs;				/* vs sequense number */
		uchar 			vr;				/* vr sequence number */
		uchar 			va;				/* va sequence number */
		uchar			header_size;	/* frame header size */
		WORD 			size_total;		/* frame total size */
		uchar			dl_state;		/* DL state */
		uchar			data [Max (DL_MX_FRAME_HEADER, 8)];	/* frame header or frmr */
};

#define Mdl_error_entity_origination	((struct mdl_error  *)p_data) -> dl_report.entity_origination
#define Mdl_error_report_type			((struct mdl_error  *)p_data) -> dl_report.report_type

#define Mdl_error_event_from			((struct mdl_error  *)p_data) -> event_from
#define Mdl_error_code					((struct mdl_error  *)p_data) -> code
#define Mdl_error_cause					((struct mdl_error  *)p_data) -> cause
#define Mdl_error_sapi					((struct mdl_error  *)p_data) -> sapi
#define Mdl_error_tei					((struct mdl_error  *)p_data) -> tei
#define Mdl_error_ces					((struct mdl_error  *)p_data) -> ces
#define Mdl_error_chani					((struct mdl_error  *)p_data) -> chani
#define Mdl_error_cr					((struct mdl_error  *)p_data) -> cr
#define Mdl_error_format				((struct mdl_error  *)p_data) -> format
#define Mdl_error_command				((struct mdl_error  *)p_data) -> command
#define Mdl_error_pf					((struct mdl_error  *)p_data) -> pf
#define Mdl_error_ns					((struct mdl_error  *)p_data) -> ns
#define Mdl_error_nr					((struct mdl_error  *)p_data) -> nr
#define Mdl_error_vs					((struct mdl_error  *)p_data) -> vs
#define Mdl_error_vr					((struct mdl_error  *)p_data) -> vr
#define Mdl_error_va					((struct mdl_error  *)p_data) -> va
#define Mdl_error_header_size			((struct mdl_error  *)p_data) -> header_size
#define Mdl_error_size_total			((struct mdl_error  *)p_data) -> size_total
#define Mdl_error_dl_state				((struct mdl_error  *)p_data) -> dl_state
#define Mdl_error_a_data	   			&((struct mdl_error  *)p_data) -> data [0]

#define Mdl_error_size					sizeof (struct mdl_error)


			/* Extra error codes */

/*

		FROM DL ENTITY :

		Q.921 code +

	T : invalid frame (2.9), minimum size (case b).
	U : invalid frame (2.9), octet address (case e).
	V : invalid frame (2.9), unknown sapi or tei(or DLCI) (case f).
	W : incorrect header size.
	X : unexpected event.

		FROM MDL ENTITY :

	a : illegal UI message size.
	b : illegal message entity ID.
	c : illegal extention address bit.
	d : illegal message type.
	e : TEI already assigned.
	f : illegal TEI in an Identity assigned message.
	g : removal of a non-automatic TEI.
	h : request assignment of a non-automatic TEI already removed,
	i : N202 retries.

*/

/*--------------------------------------------------------------------------*/

		/*	MDL INFORMATION CONFIRM : DL to MDL for information reporting. */

#define DL_ERR_TYPE_NB		'Z'-'A'+1		/* nb of  DL error counters */
#define MDL_ERR_TYPE_NB		'z'-'a'+1		/* nb of MDL error counters */

struct mdl_info {
	struct sm_info		dl_info;			/* information global structure */

	DWORD				nb_tx_frame;		/* number of Tx frame */
	DWORD				nb_rx_frame;		/* number of Rx frame */
	DWORD				nb_tx_i;			/* number of Tx I frame */
	DWORD				nb_rx_i;			/* number of Rx I frame */
	DWORD				nb_tx_rr;			/* number of Tx RR frame */
	DWORD				nb_rx_rr;			/* number of Rx RR frame */
	WORD				nb_tx_reject;		/* number of Tx REJ frame */
	WORD				nb_rx_reject;		/* number of Rx REJ frame */
	WORD				nb_tx_rnr;			/* number of Tx RNR frame */
	WORD				nb_rx_rnr;			/* number of Rx RNR frame */
	WORD				nb_t200_expiry;		/* number of T200 expiry */
	WORD  			err_dl [DL_ERR_TYPE_NB];	/* DL error count by type of error */
	WORD  			err_mdl[MDL_ERR_TYPE_NB];	/* MDL error count by type of error */
};

#define Mdl_info_entity_origination		((struct mdl_info  *)p_data) -> dl_info.entity_origination
#define Mdl_info_type					((struct mdl_info  *)p_data) -> dl_info.info_type
#define Mdl_info_nb_tx_frame			((struct mdl_info  *)p_data) -> nb_tx_frame
#define Mdl_info_nb_rx_frame			((struct mdl_info  *)p_data) -> nb_rx_frame
#define Mdl_info_nb_t200_expiry			((struct mdl_info  *)p_data) -> nb_t200_expiry
#define Mdl_info_nb_tx_i				((struct mdl_info  *)p_data) -> nb_tx_i
#define Mdl_info_nb_rx_i				((struct mdl_info  *)p_data) -> nb_rx_i
#define Mdl_info_nb_tx_reject			((struct mdl_info  *)p_data) -> nb_tx_reject
#define Mdl_info_nb_rx_reject			((struct mdl_info  *)p_data) -> nb_rx_reject
#define Mdl_info_nb_tx_rr				((struct mdl_info  *)p_data) -> nb_tx_rr
#define Mdl_info_nb_rx_rr				((struct mdl_info  *)p_data) -> nb_rx_rr
#define Mdl_info_nb_tx_rnr				((struct mdl_info  *)p_data) -> nb_tx_rnr
#define Mdl_info_nb_rx_rnr				((struct mdl_info  *)p_data) -> nb_rx_rnr
#define Mdl_info_a_dl_err			  &(((struct mdl_info  *)p_data) -> err_dl  [0])
#define Mdl_info_a_mdl_err			  &(((struct mdl_info  *)p_data) -> err_mdl [0])

#define Mdl_info_size					sizeof (struct mdl_info)

/*--------------------------------------------------------------------------*/

		/*
			MDL ASSIGN REQUEST : negotiation/indication of a TEI, parameters
			values and optional procedures.

		*/

struct mdl_assign {
		WORD		n201_tx;	/* maximum number of octets in a transmitted information field (N401) */
		WORD		n201_rx;	/* maximum number of octets in a received information field (N401) */
		uchar		k_tx;		/* window size transmit direction (k) */
		timer_val_t	t200;		/* Timer T200 */

#		if (DL_LAPF == ON) && ((DL_LAPF_ADD_FF_3 == ON) || (DL_LAPF_ADD_FF_4 == ON))
			DWORD	tei;		/* TEI value or DLCI value */

#		else

			WORD	tei;		/* TEI value or DLCI value */
#		endif

};

#define Mdl_assign_tei			((struct mdl_assign  *)p_data) -> tei
#define Mdl_assign_dlci			((struct mdl_assign  *)p_data) -> tei
#define Mdl_assign_n201_tx		((struct mdl_assign  *)p_data) -> n201_tx
#define Mdl_assign_n201_rx		((struct mdl_assign  *)p_data) -> n201_rx
#define Mdl_assign_k_tx			((struct mdl_assign  *)p_data) -> k_tx
#define Mdl_assign_t200			((struct mdl_assign  *)p_data) -> t200
#define Mdl_assign_size			sizeof (struct mdl_assign)

/*--------------------------------------------------------------------------*/

		/* 	LAPF and LAP4K : MDL DLCI MANAGEMENT : MDL_AS_DLCI_RQ/CO/RS/IN */

struct mdl_dlci {
		uchar			return_code;	/* return code : OK or NOK */

#		if (DL_LAPF == ON) && ((DL_LAPF_ADD_FF_3 == ON) || (DL_LAPF_ADD_FF_4 == ON))
			DWORD		dlci_val;		/* DLCI value */

#		else

			WORD		dlci_val;		/* DLCI value */
#		endif

		uchar 			dlci_k_tx;		/* Tx window size ( 0 ==> configuration value)*/
		timer_val_t		dlci_t200;		/* timer T200 ( 0 ==> configuration value) */
		WORD			dlci_n201_tx;	/* I Tx frame maximum size ( 0 ==> configuration value)*/
		WORD			dlci_n201_rx;	/* I Rx frame maximum size ( 0 ==> configuration value)*/
};

#define Mdl_dlci_ret_code		((struct mdl_dlci  *)p_data) -> return_code
#define Mdl_dlci_val			((struct mdl_dlci  *)p_data) -> dlci_val
#define Mdl_dlci_k_tx			((struct mdl_dlci  *)p_data) -> dlci_k_tx
#define Mdl_dlci_t200			((struct mdl_dlci  *)p_data) -> dlci_t200
#define Mdl_dlci_n201_tx		((struct mdl_dlci  *)p_data) -> dlci_n201_tx
#define Mdl_dlci_n201_rx		((struct mdl_dlci  *)p_data) -> dlci_n201_rx
#define Mdl_dlci_size			sizeof (struct mdl_dlci)

			/* Return codes */

#define MDL_DLCI_NOT_ACCEPTED		0
#define MDL_DLCI_ACCEPTED			1

#define MDL_DLCI_ALREADY_USED		2
#define MDL_DLCI_NOT_USED			3

#define MDL_DLCI_CES_NOT_USED		4
#define MDL_DLCI_CES_ALREADY_USED	5

#define MDL_DLCI_INVALID			6

#define MDL_DLCI_RM_UPON_ERROR		7

/*--------------------------------------------------------------------------*/

						/* DL ASSIGNMENT : USER <--> SM <--> MDL <--> DL */

#ifndef DL_MLP_MX_SLP
#	define DL_MLP_MX_PH_CHANNEL		2		/* number of channel in the MLP option */

#else

#	define DL_MLP_MX_PH_CHANNEL		DL_MLP_MX_SLP
#endif

struct dl_assignment {
	uchar		return_code;	/* return code */

	sapi_t		sapi;			/* DL SAPI */
	ces_t		ces;			/* DL CES */

	add_t		chani;			/* PH CHANI */
	uchar		role;			/* role : DL_DTE or DL_DCE (LAPB)*/
	WORD		lli;			/* LLI for V.120 or vc_id for LAPF */
	ent_id_t    from;			/* entity origination */

	struct mlp {
		add_t	ph_nai;			/* MLP PH NA ID : if NAI_NIL current NAI */
		sapi_t	ph_sapi;		/* MLP PH SAP ID */
		add_t	ph_chani;		/* MLP PH CHANNEL ID */
		uchar	return_code;	/* return code : OK or NOK */
	} mlp [DL_MLP_MX_PH_CHANNEL];

};

#define Dl_ass_ret_code					((struct dl_assignment  *)p_data) -> return_code
#define Dl_ass_sapi						((struct dl_assignment  *)p_data) -> sapi
#define Dl_ass_ces						((struct dl_assignment  *)p_data) -> ces
#define Dl_ass_chani					((struct dl_assignment  *)p_data) -> chani
#define Dl_ass_role						((struct dl_assignment  *)p_data) -> role
#define Dl_ass_lli						((struct dl_assignment  *)p_data) -> lli
#define Dl_ass_vc_id					((struct dl_assignment  *)p_data) -> lli
#define Dl_ass_from						((struct dl_assignment  *)p_data) -> from

#define Dl_ass_mlp_ph_nai(xx)			((struct dl_assignment  *)p_data) -> mlp [xx].ph_nai
#define Dl_ass_mlp_ph_sapi(xx)			((struct dl_assignment  *)p_data) -> mlp [xx].ph_sapi
#define Dl_ass_mlp_ph_chani(xx)			((struct dl_assignment  *)p_data) -> mlp [xx].ph_chani
#define Dl_ass_mlp_ph_return_code(xx)	((struct dl_assignment  *)p_data) -> mlp [xx].return_code

#define DL_ASS_SIZE						sizeof (struct dl_assignment)

#define	DL_DTE							'T'				/* DTE role */
#define	DL_DCE							'C'				/* DCE role */

/*--------------------------------------------------------------------------*/

						/* DL CONFIGURATION DATA */

#ifndef DL_MX_DLCEP
#	if EQUIPMENT == TE
#		define DL_MX_DLCEP		3				/* maximum number of data link connection end point per SAP in a TE */
#	else
#		define DL_MX_DLCEP		10				/* maximum number of data link end point per SAP in a NT2 */
#	endif
#endif

#if EQUIPMENT == TE
#	define DL_MX_DLCEP_SIG_BRI	2				/* maximum number of DLCEP used by the NS entity */
#	define DL_MX_DLCEP_SIG_PRI	2				/* maximum number of DLCEP used by the NS entity */
#else
#	define DL_MX_DLCEP_SIG_BRI	9				/* maximum number of DLCEP used by the NS entity for a BRI multipoint access */
#	define DL_MX_DLCEP_SIG_PRI	2				/* maximum number of DLCEP used by the NS entity for a PRI multipoint access */
#endif

			/*  Data link configuration structure */

struct dl_config {

	struct  confirm	dl_confirm;					/* confirmation structure */
	nai_t 	na_nb;								/* number of network access in the configuration message */

#	if DL_MLP == ON
		uchar	mlp_flag;						/* DL flag if OFF --> DL config else MLP config */
#	endif

	struct object {

			/* Network Acess (NA) */

		struct na {
			nai_t			nai;				/* NAI value */
			uchar 			type; 		       	/* type of network access : BRI, PRI, CSI, CSI_HDTM, PRI_MULTI_D */
			uchar			fct;				/* functional grouping TE (DTE) , NT, NET (DCE) */
			add_t			channel_nb;			/* maximum number of channel ID managed by DL */
			sapi_t 			sap_nb;				/* number of SAP's into the access */
			uchar			tei [DL_MX_DLCEP]; 	/* manual tei's values or 127 for automatic Tei [0] = broadcast */
/* NMS_FIX SS_FS 081899 automatic establishment of data link after a PH_ACT_IN */
            uchar           auto_dl_est_rq_enabled; /* Enable automatic establishment of DL */
			WORD			tei_time_assignment;/* TEI time assignment at : CONFIGURATION, NA ACTIVATION or USAGE time*/
			WORD			tei_time_removal;	/* TEI time removal at    : NA DEACTIVATION, POWER DOWN */

#			if DL_PH_MUX == ON
				uchar		ph_mux;				/* PH MUX : ON or OFF */
				nai_t		ph_nai;				/* Redirection NAI of PH accesses */
#			endif

#			if DL_LAPX == ON
				timer_val_t dlx_xt1_a;			/* LAPX XT1 originator timer value */
				timer_val_t	dlx_xt1_o;			/* LAPX XT1 answerer timer value */
#			endif

#			if DL_LAPF == ON


					/*
						In a TDMA access physical channel are switched under
						Call Control.
						In one channel it is possible to establish several
						Virtual Circuits.
						A Virtual channel is used to structure a channel which
						will be attached to a physical channel under Call Control.

						For a Single Channel Access a one to one mapping is used.

					*/

				struct lapf_vc {
					uchar	vc_id;				/* Virtual channel ID : 1, 2, ... or DL_VC_ID_NIL = END OF LIST */
					uchar	nb_dlci;			/* number of DLCI in the Virtual Channel */

#					if (DL_LAPF == ON) && ((DL_LAPF_ADD_FF_3 == ON) || (DL_LAPF_ADD_FF_4 == ON))
						DWORD	dlci [DL_LAPF_MX_DLCI];	/* DLCI value */

#					else

						WORD	dlci [DL_LAPF_MX_DLCI];	/* DLCI value */
#					endif

				} lapf_vc [DL_LAPF_CONFIG_MX_VC];

#			endif
            uchar   data_co;   /* Enable/disable DL_DA_CO generation */
		} na;

			/* Service Access Point (SAP) */

		struct sap {
			sapi_t 			sapi;				/* SAPI value */
			ent_id_t		dl_entity_id;		/* DL entity id (protocol ID) :
														. ENT_DL_D (LAPD),
														. ENT_DL_B (LAPB)
														. ENT_DL_V120 (V.120)
														. ENT_DL_F (LAPF)
														. ENT_DL_4K (LAP4K) */
			uchar 			modulo;				/* modulo value (8 or 128) */
			uchar 			k;					/* window size */
			timer_val_t		ti_0;				/* timer T200 value (0 for implicit value) */
			timer_val_t		ti_1;				/* timer T203 value (0 for implicit value) */
			timer_val_t		ti_tap;				/* (DL_SAPI_MDL only) timer T202 (TE-side, TEI-Request) or T201 (NT-side, TEI-Check-Response) */
			uchar 			rc_nb;				/* maximum retry number */
			add_t 			dlcep_nb;			/* number of connection endpoints */
			WORD			n201;				/* I frame maximum size */
			ent_id_t		l3_entity_id;		/* L3 entity id */

#			if DL_FC == ON
				uchar		out_fc_low_mark;	/* outgoing flow control low mark */
				uchar		out_fc_high_mark;	/* outgoing flow control high mark */
#			endif

#			if DL_XID == ON || DL_IDENTIFICATION == ON
				timer_val_t	xid_ti_val;			/* XID retransmission timer value */
				uchar		xid_rc_max;			/* XID retransmission max value */

#				if DL_IDENTIFICATION == ON
					uchar	ident_profile_nb; 	/* identification profile number */
#				endif

#			endif

#			if DL_ISDN_BIOS == ON
				uchar		isdn_bios;			/* ISDN-BIOS LAPB facilities ON or OFF in thz SAP */
#			endif

			uchar			no_congestion;		/* OFF : congestion is managed / ON : no congestion management */
			uchar			teledisket;			/* teledisket profile : ON or OFF */

#			if DL_LAPF == ON
				uchar		lapf_add_ff;		/* Lapf address field format */
				uchar       lapf_de;			/* Lapf Dicard elligibility */
				uchar		lapf_dc;			/* DLCI or DL-CORE */
#			endif

		} sap [DL_CONFIG_MX_SAP];

	} object [DL_CONFIG_MX_NA];

	uchar	att_ni_flag;						/* AT&T, NI or Northern Telecom option flag :
													OFF		Other network
													DL_ATT	AT&T Network
													DL_NI	National ISDN
													DL_NT   Nothern Telecom
												*/

#	if DL_IDENTIFICATION == ON

			/* IDENTIFICATION PROFILE LIST */

		struct ident_profile {
			uchar	ident_flag;					/* identification flag : ON or OFF */
			uchar	id  [DL_ID_SIZE];			/* identity string value */
			uchar	sig [DL_SIG_SIZE];			/* signature string value */
		} ident_profile [DL_CONFIG_MX_IDENT_PROFILE];

#	endif

#	if DL_RELAY == ON

			/* RELAYING */

		struct relay {
			uchar	flag;						/* relay FLAG ON or OFF */

			nai_t	nai_1;						/* NAI  connection 1 */
			sapi_t	sapi_1;						/* SAPI connection 1 */
			ces_t	ces_1;						/* CES  connection 1 */

			nai_t	nai_2;						/* NAI  connection 2 */
			sapi_t	sapi_2;						/* SAPI connection 2 */
			ces_t	ces_2;						/* CES  connection 2 */
		} relay [DL_CONFIG_MX_RELAY];

#	endif

};

	/* Manipulation macro's thru p_dl_config p_dl_config_na p_dl_config_sap pointers */

#define Dl_config_ret_code				p_dl_config -> dl_confirm.return_code	/* return code */
#define Dl_config_cause					p_dl_config -> dl_confirm.cause			/* cause */
#define Dl_config_diagnostic			p_dl_config -> dl_confirm.diagnostic	/* diagnostic */

#define Dl_config_na_nb					p_dl_config -> na_nb					/* number of network access */

#if DL_MLP == ON
#	define Dl_config_mlp_flag			p_dl_config -> mlp_flag
#endif

#define Dl_config_att_ni_flag			p_dl_config -> att_ni_flag					/* AT&T option flag */
#define Dl_config_object_na(xx)			p_dl_config -> object[xx].na			/* nai */
#define Dl_config_object_sap(xx,yy) 	p_dl_config -> object[xx].sap[yy]		/* sapi */

#define Dl_config_nai 					p_dl_config_na -> nai					/* NAI */
#define Dl_config_type 					p_dl_config_na -> type					/* type of network access */
#define Dl_config_fct 					p_dl_config_na -> fct					/* functional grouping */
#define Dl_config_channel_nb    		p_dl_config_na -> channel_nb			/* number of B channels */
#define Dl_config_sap_nb				p_dl_config_na -> sap_nb				/* number of SAP */

#define Dl_config_tei(xx)				p_dl_config_na -> tei[xx]				/* manual TEI table */

#define Dl_config_tei_time_assignment	p_dl_config_na -> tei_time_assignment	/* TEI assignment time */
#define Dl_config_tei_time_removal		p_dl_config_na -> tei_time_removal		/* TEI removal time */

/* NMS_FIX SS_FS 081899 automatic establishment of data link after a PH_ACT_IN */
#define Dl_config_auto_dl_est_rq_enabled p_dl_config_na -> auto_dl_est_rq_enabled /* Enable automatic establishment of DL */
#define Dl_config_data_co               p_dl_config_na -> data_co

#define Dl_config_ph_mux				p_dl_config_na -> ph_mux
#define Dl_config_ph_nai				p_dl_config_na -> ph_nai

#define Dl_config_dlx_xt1_o				p_dl_config_na -> dlx_xt1_o				/* LAPX XT1 timer value answerer */
#define Dl_config_dlx_xt1_a				p_dl_config_na -> dlx_xt1_a				/* LAPX XT1 timer value answerer */

#define Dl_config_sapi					p_dl_config_sap -> sapi					/* sapi */
#define Dl_config_dl_entity_id			p_dl_config_sap -> dl_entity_id			/* DL entity identifier */
#define Dl_config_l3_entity_id			p_dl_config_sap -> l3_entity_id			/* L3 entity identifier */
#define Dl_config_modulo				p_dl_config_sap -> modulo				/* modulo value */
#define Dl_config_k						p_dl_config_sap -> k					/* window size */
#define Dl_config_ti_0					p_dl_config_sap -> ti_0					/* timer value */
#define Dl_config_ti_1					p_dl_config_sap -> ti_1					/* timer value */
#define Dl_config_ti_tap				p_dl_config_sap -> ti_tap				/* tap timer value */
#define Dl_config_rc_nb					p_dl_config_sap -> rc_nb				/* retry count initial value */
#define Dl_config_dlcep_nb				p_dl_config_sap -> dlcep_nb				/* number of connection endpoint inside the SAP */
#define Dl_config_n202					p_dl_config_sap -> rc_nb				/* TEI Identity request transmission count initial value */
#define Dl_config_n201					p_dl_config_sap -> n201
#define Dl_config_no_congestion			p_dl_config_sap -> no_congestion
#define Dl_config_teledisket			p_dl_config_sap -> teledisket

#define Dl_config_out_fc_low_mark		p_dl_config_sap -> out_fc_low_mark
#define Dl_config_out_fc_high_mark		p_dl_config_sap -> out_fc_high_mark

#define Dl_config_xid_ti_val			p_dl_config_sap -> xid_ti_val
#define Dl_config_xid_rc_max			p_dl_config_sap -> xid_rc_max

#define Dl_config_ident_profile_nb		p_dl_config_sap -> ident_profile_nb

#define Dl_config_isdn_bios				p_dl_config_sap -> isdn_bios

#define Dl_config_lapf_add_ff			p_dl_config_sap -> lapf_add_ff
#define Dl_config_lapf_de				p_dl_config_sap -> lapf_de
#define Dl_config_lapf_dc				p_dl_config_sap -> lapf_dc

#define Dl_config_ident_profile_flag(xx)  	p_dl_config -> ident_profile[xx].ident_flag
#define Dl_config_ident_profile_a_id(xx)	&(p_dl_config -> ident_profile[xx].id[0])
#define Dl_config_ident_profile_a_sig(xx)	&(p_dl_config -> ident_profile[xx].sig[0])

#if DL_RELAY == ON
#	define Dl_config_relay_flag(xx)  	p_dl_config -> relay[xx].flag
#	define Dl_config_relay_nai_1(xx)  	p_dl_config -> relay[xx].nai_1
#	define Dl_config_relay_sapi_1(xx)  	p_dl_config -> relay[xx].sapi_1
#	define Dl_config_relay_ces_1(xx)  	p_dl_config -> relay[xx].ces_1
#	define Dl_config_relay_nai_2(xx)  	p_dl_config -> relay[xx].nai_2
#	define Dl_config_relay_sapi_2(xx)  	p_dl_config -> relay[xx].sapi_2
#	define Dl_config_relay_ces_2(xx)  	p_dl_config -> relay[xx].ces_2
#endif

#if DL_LAPF == ON
#	define Dl_config_lapf_vc_id(xx)			p_dl_config_na -> lapf_vc [xx].vc_id
#	define Dl_config_lapf_vc_nb_dlci(xx)	p_dl_config_na -> lapf_vc [xx].nb_dlci
#	define Dl_config_lapf_vc_dlci(xx,yy) 	p_dl_config_na -> lapf_vc [xx].dlci [yy]
#endif

						/* Network Access type */

#define DL_POINT_TO_POINT				PRI			/* Point to Point access type */
#define DL_POINT_TO_MULTIPOINT			BRI			/* Point to multipoint access type */
#define DL_MULTIPOINT_TO_POINT			BRI			/* Multipoint to point access type */


						/* DL TEI management */

#define DL_TEI_ASSIGNMENT				'a'			/* TEI to add */
#define DL_TEI_REMOVAL					'b'			/* TEI to remove */

						/* TEI assignment and removal time */

#define DL_TEI_TIME_ACTIVATION			0x0001		/* TEI time is line activation */
#define DL_TEI_TIME_DEACTIVATION		0x0002		/* TEI time is line deactivation */
#define DL_TEI_TIME_CONFIGURATION		0x0004		/* TEI time is configuration */
#define DL_TEI_TIME_USER_ACTION			0x0008		/* TEI time is user action */
#define DL_TEI_TIME_POWER_ON			0x0010		/* TEI time is line power on */
#define DL_TEI_TIME_POWER_OFF			0x0020		/* TEI time is line power off */
#define DL_TEI_TIME_TEI_REMOVAL			0x0040		/* TEI time is received of a REMOVAL message from the network */
#define DL_TEI_TIME_TEI_DENIED			0x0080		/* TEI time is received of a DENIED message from the network */
#define DL_TEI_TIME_ASSIGN_FAILED		0x0100		/* TEI time is if TEI assignment failed (permanent polling for NI-2 (North america) */
#define DL_TEI_TIME_NIL					0x0000		/* TEI time is not define */

						/* Timer value NIL --> no timer in use */

#define DL_TIMER_NIL					(timer_val_t)(~0)

						/* Virtual Channel ID NIL */

#define DL_VC_ID_NIL 					(0)

						/* North America variants */

#define DL_ATT							ON			/* AT&T layer 2 (ON for compatibility with older releases) */
#define DL_NI							'n'			/* National ISDN layer 2 (BellCore) */
#define	DL_NT							't'			/* Northern Telecom */
#define DL_TWN                          'T'         /* Taiwan */

/*--------------------------------------------------------------------------*/

								/* V.120 SYNC parameters */

#define DL_V120_ADDRESS_SIZE			2				/* V.120 address field size 	*/
#define DL_V120_CTRL_UI_SIZE			2				/* V.120 UI control field size 	*/
#define DL_V120_CTRL_UI_CODING	 		(uchar)0x13		/* V.120 UI coding value 		*/
#define DL_V120_HEADER_SIZE				1				/* V.120 header size 			*/
#define DL_V120_BT_HEADER_CODING		(uchar)0x83		/* V.120 BT header coding :  E=0, BR=0, C2=C1=0, B=F=1	*/
#define DL_V120_HDLC_HEADER_CODING		(uchar)0x83		/* V.120 HDLC header coding :  E=0, BR=0, C2=C1=0, B=F=1	*/

/*--------------------------------------------------------------------------*/

					/* FUNCTION DECLARATION */


#	if DL_SIM_BUILDER == OFF
#		define  	build_sdu_n_to_dl		FCT_NIL
#		define  	build_sdu_n_to_mdl		FCT_NIL
#		define		build_sdu_mdl_to_dl_b	FCT_NIL
#		define		build_sdu_ti_to_dl		FCT_NIL
#		define		build_sdu_ph_d_to_dl_d	FCT_NIL
#		define		build_sdu_ph_to_dl		FCT_NIL
#	endif

#	if DL_SIM_ANALYSER == OFF
#		define		ana_sdu_dl				FCT_NIL
#		define		ana_sdu_mdl				FCT_NIL
#		define		ana_sdu_ti_dl			FCT_NIL
#	endif

#	if NEW_FCT_STYLE == ON
		uchar		dl					(struct message  *p_msg);
		uchar 		mdl					(struct message  *p_msg);

		void		dl_var_init			(void);
		void		mdl_var_init		(void);

#		if DL_SIM_BUILDER == ON
			uchar  	build_sdu_n_to_dl	(void);
			uchar  	build_sdu_n_to_mdl	(void);
			uchar	build_sdu_mdl_to_dl_b(void);
			uchar	build_sdu_ti_to_dl	(void);
			uchar 	build_sdu_ph_d_to_dl_d(void);
			uchar	build_sdu_ph_to_dl	(void);
			uchar	simul_tap  			(void);
#		endif

#		if DL_SIM_ANALYSER == ON
			uchar	ana_sdu_dl			(struct message  *p_msg);
			uchar	ana_sdu_mdl			(struct message  *p_msg);
			uchar	ana_sdu_ti_dl		(struct message  *p_msg);
			void	pr_frame			(uchar direction);
#		endif

#	else
		uchar 		dl					();
		uchar 		mdl					();

		void		dl_var_init			();
		void		mdl_var_init		();

#		if DL_SIM_BUILDER == ON
			uchar  	build_sdu_n_to_dl	();
			uchar  	build_sdu_n_to_mdl	();
			uchar	build_sdu_mdl_to_dl_b();
			uchar	build_sdu_ti_to_dl	();
			uchar 	build_sdu_ph_d_to_dl_d();
			uchar	build_sdu_ph_to_dl	();
			uchar	simul_tap 			();
#		endif

#		if DL_SIM_ANALYSER == ON
			uchar	ana_sdu_dl			();
			uchar	ana_sdu_mdl			();
			uchar	ana_sdu_ti_dl		();
			void	pr_frame			();
#		endif

#	endif

/*--------------------------------------------------------------------------*/

#endif
#ifdef __cplusplus
}
#endif

/*EOF*/
